var trim = function(str){
  return str ? str.replace(/(^\s+)|(\s+$)/g,"") : str;
};

var serverURL = getApp().requestURLPrefix;

var request = function(obj){
  if (!obj){
    console.error("obj not defined");
    return false;
  }
  wx.request({
    header: {
      "Content-Type": "application/x-www-form-urlencoded",
      "Authorization": "Basic NTk2NTY6NTY5NTk1OTU="
    },
    url: serverURL + obj.url,
    data: obj.data,
    method: obj.method,
    success: obj.success,
    dataType: obj.dataType,
    responseType: obj.responseType,
    fail: obj.fail,
    complete: obj.complete
  });
}

module.exports = {
  trim: trim,
  request: request
}